﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{

    public partial class TeamTransfers : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!HttpContext.Current.User.Identity.IsAuthenticated)
            //    Response.Redirect("Default.aspx");

            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];

            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.TeamTransfers_PageTitle;
            //this.Title = GND.ReturnAppTitle();
            
            //if (ou.TeamId == "Null")
            //    Response.Redirect("~/GeneralMessage.aspx?MessageString=M74ggdizz5wfeh");

            string TeamId = null;
            if (Request.QueryString["Id"] != null)
            {
                TeamId = Request.QueryString["Id"].ToString();
            }
            if (TeamId == null && ou.TeamId != null)
                TeamId = ou.TeamId;
            if (TeamId == null)
                Response.Redirect("~/Default.aspx");

            
            if (!IsPostBack)
            {
                this.SqlDataSource1.SelectParameters.Add("TeamId", TeamId);
                this.SqlDataSource1.SelectParameters.Add("Language", ou.Language);
                this.SqlDataSource2.SelectParameters.Add("TeamId", TeamId);
            }
            
        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }

        protected string FormattedNumber(object Num)
        {
            decimal ReturnValue;

            if (decimal.TryParse(Num.ToString(), out ReturnValue))
                return (ReturnValue.ToString("N0"));
            return "";
        }
    }
}